<template>
  <div>
    <el-card style="margin-bottom: 10px;">
      <div slot="header">
        <span>当前账户限制</span>
      </div>

      <el-table border :data="[tableData]" class="el-table-align-center">
        <el-table-column prop="dailyRecharge" label="每天充值限额">
          <template slot-scope="{row}">
            {{row.dailyRecharge || '没有限制'}}
          </template>
        </el-table-column>
        <el-table-column prop="dailyTransfer" label="每天转账限额">
          <template slot-scope="{row}">
            {{row.dailyTransfer || '没有限制'}}
          </template>
        </el-table-column>
        <el-table-column prop="lockDays" label="锁定周期">
          <template slot-scope="{row}">
            {{row.lockDays || '没有锁定'}}
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-card>
      <div slot="header">
        <span>账户锁定</span>
      </div>
      <el-table border :data="tableData.logList" class="el-table-align-center">
        <el-table-column label="锁定时间">
          <template slot-scope="{row}">
            {{row.startDate | toTime}}
          </template>
        </el-table-column>
        <el-table-column label="解锁时间">
          <template slot-scope="{row}">
            {{row.endDate | toTime}}
          </template>
        </el-table-column>
        <el-table-column label="状态">
          <template slot-scope="{row}">
            <span v-if="row.status === 0">
              正常
            </span>
            <span v-else>
              已删除
            </span>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="{row}">
            <el-button type="text" @click="()=>delLock(row)" v-if="row.status === 0">删除</el-button>
            <span v-else>---</span>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
  import { getMemberSecurity,clearMemberSecurity } from '@/services/api/member'
  import {form} from '@/build';
  export default {
    name: "member-security",
    props: {
    },
    mixins:[form],
    data(){
      return{
        tableData: {
          logList:[]
        },
      }
    },
    mounted(){
      this.bindGet(getMemberSecurity,'tableData',{
        sendingData: {userId: this.$store.state.member.member_id},
        format: data=>{
          return data?data:{}
        }
      });
      this.getAll();
    },
    methods:{
      delLock(row){
        const {id}= row;
        clearMemberSecurity({logId:id}).then(([result,data])=>{
          if(result){
            this.$notify({
              type:'success',
              message: '清除用户锁定限制成功'
            });
            this.getAll();
          }
        })
      }
    }

  }
</script>

<style scoped>
  .edit-input {
    padding-right: 100px;
  }

  .cancel-btn {
    position: absolute;
    right: 15px;
    top: 10px;
  }
</style>
